package cn.gson.boot.model.dao;

import cn.gson.boot.model.pojos.Dingdan;
import cn.gson.boot.model.pojos.Hetong;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;
import java.util.List;

public interface DinDanDao extends CrudRepository<Dingdan,Integer> {
    /*//根据合同id来移除合同 （逻辑删除）
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update hetong set ht_ys=0 where ht_id=?1")
    public void yichuHeTong(Integer htid);*/

    //根据订单id来移除订单 （逻辑删除）
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update dingdan set dd_ys=0 where dd_id=?1")
    public void yichuDingDan(Integer ddid);
    //根据订单id来移除订单 （物理删除）
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "delete from dingdan where dd_id=?1")
    public void deleteDingDan(Integer ddid);


    //修改实回款
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update dingdan set dd_hkmoney=?1 where dd_id=?2")
    public void updatShiHuiKuan(double shihuiKuan,Integer ddId);

    //修改订单状态
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update dingdan set dd_zhuangtai=?1 where dd_id=?2")
    public void updateDingDanZt(String  zt,Integer ddId);


    //修改换货生成的订单的出库状态
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update dingdan set dd_ishhch=?1 where dd_id=?2")
    public void updateHHDDchuKu(Integer ckzt,Integer ddId);


    //谭龙俊的客户合并（订单表）
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "update dingdan set k_id = ?1 where k_id=?2")
    public void kehuhebing(Integer b,Integer a);

    //谭龙俊的客户合并（订单表查询）
    @Query(nativeQuery = true,value = "select * from dingdan where  k_id = ?1")
    public List<Dingdan> dingdancha(Integer a);
}
